//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo1AND20;

public class demo20 {
    public demo20() {
    }

    public static void main(String[] args) {
        System.out.println(isValid("([)]"));
    }

    public static boolean isValid(String s) {
        StringBuilder sb = new StringBuilder(s);

        while(sb.indexOf("(") != -1 && sb.indexOf(")") != -1 && sb.indexOf("(") < sb.indexOf(")")) {
            sb.delete(sb.indexOf("("), sb.indexOf(")") + 1);
        }

        while(sb.indexOf("{") != -1 && sb.indexOf("}") != -1 && sb.indexOf("{") < sb.indexOf("}")) {
            sb.delete(sb.indexOf("{"), sb.indexOf("}") + 1);
        }

        while(sb.indexOf("[") != -1 && sb.indexOf("]") != -1 && sb.indexOf("[") < sb.indexOf("]")) {
            sb.delete(sb.indexOf("["), sb.indexOf("]") + 1);
        }

        return sb.isEmpty();
    }
}
